package cn.xfdzx.android.apps.shop.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.CarCouponsBeen;
import cn.xfdzx.android.apps.shop.bean.SelectAddressBeen;

/**
 * @author gzk
 * @date 2020/3/28 0028
 * description：地址
 */
public class SelectAddressLVAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<SelectAddressBeen> mList;
    private ImageView iv_default_select;

    private TextView tv_chaochu;
    private TextView tv_type_address;
    private TextView tv_address;
    private ImageView iv_modify;
    private TextView tv_name;
    private TextView tv_phone;
    public SelectAddressLVAdapter(Context mContext, ArrayList<SelectAddressBeen> mList){
        this.mContext=mContext;
        this.mList=mList;
        addData();
    }

    private void addData() {
        mList.add(new SelectAddressBeen(true,false,"","南四环西路188号十一区7号楼5层","李先生","115616132131"));
        mList.add(new SelectAddressBeen(false,false,"家","南四环西路188号十一区7号楼5层","李先生","15854512365"));
        mList.add(new SelectAddressBeen(false,true,"","南四环西路188号十一区7号楼5层","李先生","15854512365"));
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        view=View.inflate(mContext, R.layout.item_select_address_pw,null);
        iv_default_select= view.findViewById(R.id.iv_default_select);
        tv_chaochu= view.findViewById(R.id.tv_chaochu);
        tv_type_address= view.findViewById(R.id.tv_type_address);
        tv_address= view.findViewById(R.id.tv_address);
        iv_modify= view.findViewById(R.id.iv_modify);
        tv_name=view.findViewById(R.id.tv_name);
        tv_phone=view.findViewById(R.id.tv_phone);

        if (mList.get(i).is_moren){
            iv_default_select.setImageResource(R.drawable.icon_select_address_green);
        }else {
            iv_default_select.setImageResource(R.drawable.only_look_bg_hui);
        }
          if (mList.get(i).is_chao){
              iv_default_select.setVisibility(View.GONE);
              tv_chaochu.setVisibility(View.VISIBLE);
        }else {
              iv_default_select.setVisibility(View.VISIBLE);
              tv_chaochu.setVisibility(View.GONE);
        }
          if (mList.get(i).type.isEmpty()){
              tv_type_address.setVisibility(View.GONE);
        }else {
              tv_type_address.setVisibility(View.VISIBLE);
              tv_type_address.setText(mList.get(i).type);
        }
        tv_address.setText(mList.get(i).address);
        tv_name.setText(mList.get(i).name);
        tv_phone.setText(mList.get(i).phone);
        iv_modify.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

            }
        });




        return view;
    }
}
